//
//  MyallViewController.m
//  xiaoyiNew
//
//  Created by 讯一 on 16/12/25.
//  Copyright © 2016年 讯一. All rights reserved.
//

#import "MyallViewController.h"

#import "MyfirstTableViewCell.h"

#import "secondTableViewCell.h"

#import "thirdTableViewCell.h"

#import "fourthcellTableViewCell.h"

#import "fifthTableViewCell.h"

#import "sixthTableViewCell.h"
//跳转
#import "erweimavc.h"
#import "xiaopiaoViewController.h"
#import "lishizhangdanViewController.h"
#import "renzhengViewController.h"
#import "gouwudarenViewController.h"
#import "meilizhiViewController.h"

@interface MyallViewController ()<UITableViewDelegate,UITableViewDataSource,fourthcellTableViewCellDelegate,fifthTableViewCellDelegate>

@property (nonatomic,strong)UITableView *mytableview;
//@property (nonatomic)

@end

@implementation MyallViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.navigationItem setTitle:@"我的"];
    UIBarButtonItem *rightbut = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemSave target:self action:@selector(action1)];
    self.navigationItem.rightBarButtonItem = rightbut;
    [self.view addSubview:self.mytableview];
    
}


#pragma mark -- uitableview 代理方法
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 0) {
        return 2;
    }
    return 1;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 5;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        if (indexPath.row == 1) {
            return Screen_Width/3.8;
        }else{
            return Screen_Width/3.5;
        }
    }else if (indexPath.section == 1){
        return Screen_Width/4.0;
    }else if (indexPath.section == 4){
        return Screen_Width/5.0;
    }
    
    return Screen_Width/3.0;
}


//
- (UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    if (section == 2) {
        UILabel *lab1 = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 0, 20)];
        lab1.text = @"盒子服务";
        lab1.backgroundColor = TSColor(230, 230, 230);
        return lab1;
    }else if (section == 3){
        UILabel *lab2 = [[UILabel alloc]init];
        lab2.text = @"会员服务";
        lab2.backgroundColor = TSColor(230, 230, 230);
        return lab2;
    }
    return nil;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    if (section == 2) {
        return 20;
    }else if (section == 3){
        return 25;
    }else if (section == 1){
        return 15;
    }
    return 15;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.001;
}
//
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        
        if (indexPath.row == 0) {
            MyfirstTableViewCell *cell1 = [tableView dequeueReusableCellWithIdentifier:@"myfirstcell"];
            cell1.selectionStyle = UITableViewCellSelectionStyleNone;
            return cell1;
        }else{
            secondTableViewCell *cell2 = [tableView dequeueReusableCellWithIdentifier:@"mysecondcell"];
            cell2.selectionStyle = UITableViewCellSelectionStyleNone;
            return cell2;
        }
        
    }else if (indexPath.section == 1){
        thirdTableViewCell *cell3 = [tableView dequeueReusableCellWithIdentifier:@"mythirdcell"];
        cell3.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell3;
    }else if (indexPath.section == 2){
        fourthcellTableViewCell *cell4 = [tableView dequeueReusableCellWithIdentifier:@"myfourthcell"];
        cell4.selectionStyle = UITableViewCellSelectionStyleNone;
        cell4.delegate = self;
        return cell4;
    }else if (indexPath.section == 3){
        fourthcellTableViewCell *cell5 = [tableView dequeueReusableCellWithIdentifier:@"myfifthcell"];
        cell5.selectionStyle = UITableViewCellSelectionStyleNone;
        cell5.delegate = self;
        return cell5;
    }

    sixthTableViewCell *cell6 = [tableView dequeueReusableCellWithIdentifier:@"mysixthcell"];
    cell6.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell6;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (void)action1{
    
}

#pragma mark -- delegate
-(void)act:(YTBaseButton *)sender{
    if (sender.tag == 40000) {
        erweimavc *vc = [[erweimavc alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
    }else if (sender.tag == 40001){
        xiaopiaoViewController *vc = [[xiaopiaoViewController alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
    }else if (sender.tag == 40002){
        lishizhangdanViewController *vc = [[lishizhangdanViewController alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
    
    }
}
- (void)act5:(YTBaseButton *)sender{
    if (sender.tag == 50000){
        renzhengViewController *vc = [[renzhengViewController alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
    }else if (sender.tag == 50001){
        gouwudarenViewController *vc = [[gouwudarenViewController alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
    }else if(sender.tag == 50002){
        meilizhiViewController *vc = [[meilizhiViewController alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
    }
}
    /*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
- (UITableView *)mytableview{
    if (!_mytableview) {
        _mytableview = [[UITableView alloc]initWithFrame:CGRectMake(0, 64,Screen_Width,self.view.frame.size.height - 128) style:UITableViewStyleGrouped];
        _mytableview.delegate = self;
        _mytableview.dataSource = self;
        _mytableview.backgroundColor = TSColor(230, 230, 230);
        self.mytableview.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
        [_mytableview registerClass:[MyfirstTableViewCell class] forCellReuseIdentifier:@"myfirstcell"];
        
        [_mytableview registerClass:[secondTableViewCell class] forCellReuseIdentifier:@"mysecondcell"];
        [_mytableview registerClass:[thirdTableViewCell class] forCellReuseIdentifier:@"mythirdcell"];
        [_mytableview registerClass:[fourthcellTableViewCell class] forCellReuseIdentifier:@"myfourthcell"];
        [_mytableview registerClass:[fifthTableViewCell class] forCellReuseIdentifier:@"myfifthcell"];
        [_mytableview registerClass:[sixthTableViewCell class] forCellReuseIdentifier:@"mysixthcell"];
    }
    return _mytableview;
}
@end
